package designmodel.handler;

import java.util.Arrays;

/**
 * 处理客户端
 *
 * @author scylla
 * @version V1.0
 * @project echo-java-base
 * @title 处理客户端
 * @package designmodel.handler
 * @since 2022/5/19 5:42 下午
 */
public class HandlerClient {

    public static void main(String[] args) {
        //0~10
        ConcretHandler1 concretHandler1 = new ConcretHandler1();
        //10~20
        ConcretHandler2 concretHandler2 = new ConcretHandler2();
        //20~60
        ConcretHandler3 concretHandler3 = new ConcretHandler3();
        //60 以上
        ConcretHandler4 concretHandler4 = new ConcretHandler4();

        concretHandler1.setSuccessor(concretHandler3)
                .setSuccessor(concretHandler4)
                .setSuccessor(concretHandler2);

        int[] requestArr = {1, 2, 4, 7, 23, 44, 77, 10, 60, 55, 19, -20, -19, 84};

        Arrays.stream(requestArr).forEach(concretHandler1::handleRequest);


    }
}
